﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

using BLL;
using DAL;
using Models;
using System.Data;

using System.Text;
using System.Xml;
using Web.Old_App_Code;
using System.Collections;

public partial class cn_index : System.Web.UI.Page
{
     // Fields
    protected string basicSetXmlPath = "/cn/xml/website_set.xml";
    protected BrandManager bm = new BrandManager();

    protected GroupBuyManager gbm = new GroupBuyManager();

    protected string systemNoticeXmlPath = "/cn/xml/system_notice.xml";

    // Methods
    protected StringBuilder BrandBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            DataTable brandByLanguage = this.bm.GetBrandByLanguage("zh-CN");
            if (brandByLanguage.Rows.Count > 9)
            {
                return builder;
            }
            builder.AppendLine("<div class=\"brand\">");
            builder.AppendLine("<h6>集团旗下品牌：</h6>");
            foreach (DataRow row in brandByLanguage.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<a href=\"", row["brandUrl"], "\"><img src=\"", row["brandLogo"], "\" alt=\"", row["brandName"], "\" /></a>" }));
            }
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder CategoryRightAdBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            DataTable table = this.gbm.GetGroupBuyLanguageVersionAndIsShelvesAndTop("zh-CN", 1, 3);
            builder.AppendLine("<div class=\"tuan\">");
            builder.AppendLine("<div class=\"forecast\">");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
      
    }

    protected StringBuilder SystemNoticeBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.systemNoticeXmlPath));
            XmlElement element = (XmlElement) document.SelectSingleNode("notice");
            if (element.GetAttribute("isShow") == "true")
            {
                builder.AppendLine("<div id=\"home_tx\" style=\"height: 1px\">");
                builder.AppendLine("<div class=\"home_tx\" id=\"home_tx_in\" style=\"position: absolute; top: -30px; height: 30px\">");
                builder.AppendLine("<div class=\"notice\">");
                builder.AppendLine("<img class=\"float\" src=\"" + new TemplateLoad().TemplateCssLoad() + "images/notice.png\" alt=\"系统公告\" />");
                builder.AppendLine("<div class=\"slider\">");
                builder.AppendLine("<div class=\"slice1\">");
                builder.AppendLine("<div class=\"slice2\" id=\"slider\">");
                builder.AppendLine("<ul>");
                builder.AppendLine("<li class=\"slide\"><a href=\"" + element.GetAttribute("url") + "\">" + element.InnerText + "</a></li>");
                builder.AppendLine("</ul>");
                builder.AppendLine("</div>");
                builder.AppendLine("</div>");
                builder.AppendLine("</div>");
                builder.AppendLine("<a class=\"close\" onfocus=\"this.blur()\" onclick=\"home_tx_hide();return false;\">");
                builder.AppendLine("<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/noticeclose.gif\"></a></div>");
                builder.AppendLine("</div>");
                builder.AppendLine("</div>");
                builder.AppendLine("<script src=\"" + new TemplateLoad().TemplateCssLoad() + "js/notice/notice.js\" type=\"text/javascript\"></script>");
                builder.AppendLine("<script language=\"Javascript\" type=\"text/javascript\" src=\"" + new TemplateLoad().TemplateCssLoad() + "js/notice/easySlider1.5.js\"></script>");
            }
        }
        catch
        {
        }
        return builder;
    }

    protected string TitleBind()
    {
        string attribute = "";
        try
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.basicSetXmlPath));
            attribute = ((XmlElement) document.SelectSingleNode("set/cn_title")).GetAttribute("value");
        }
        catch
        {
        }
        return attribute;
    }
}

